import sys
import functools
from PyQt5.QtCore import pyqtSlot, Qt
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout,QLabel, QInputDialog, QFileDialog, QColorDialog

user_label: QLabel

def on_create_clicked():
    text, confirm = QInputDialog.getText(w, "注册", "请输入用户名")
    print(text, confirm)
    
def init_widget(w: QWidget):
    w.setWindowTitle("输入对话框")
    w.resize(640, 480)
    layout = QHBoxLayout()
    w.setLayout(layout)
    
    btn = QPushButton("创造用户")
    btn.clicked.connect(on_create_clicked)
    
    user_label = QLabel()
    
    layout.addWidget(btn)
    layout.addWidget(user_label)
    
if __name__ == '__main__':
    # 1. 创建应用程序
    app = QApplication(sys.argv)
    # 2. 创建窗口
    w = QWidget()
    init_widget(w)
    # 3. 显示窗口
    w.show()
    # 4. 等待窗口停止
    sys.exit(app.exec_())
